<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const arr = [
        { name: '张三', score: 99, sex: '男' },
        { name: '李四', score: 100, sex: '男' },
        { name: '王武', score: 77, sex: '女' },
        { name: '张红', score: 68, sex: '男' },
      ]
      let maxScore = arr[0].score
      for (let i = 0; i < arr.length; i++) {
        if (arr[i].score > maxScore) {
          maxScore = arr[i].score
        }
      }
      let max = 0
      for (let i = 0; i < arr.length; i++) {
        if (maxScore === arr[i].score) {
          max = i
        }
      }
      console.log(arr[max])
      arr.sort(function (a, b) {
        return a.score - b.score
      })
      console.log(arr)
    </script>
  </body>
</html>
